<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>时代听令，前滩先生来了！</title>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="full-screen" content="true"/>
    <meta name="screen-orientation" content="portrait"/>
    <meta name="x5-fullscreen" content="true"/>
    <meta name="360-fullscreen" content="true"/>



    <style>
        html, body {
            /*-ms-touch-action: none;*/
            background: #000000;
            padding: 0;
            border: 0;
            margin: 0;
            height: 100%;
            overflow: hidden;
        }
    </style>
</head>
<body>
<script src="pixi.js/bin/pixi.min.js?"+Math.random()></script>
<script src="balaJS/Main.js?"+Math.random()></script>
<script src="balaJS/Hajime.js?"+Math.random()></script>
<script src="balaJS/ControlCenter.js?"+Math.random()></script>
<script src="balaJS/MusicControl.js?"+Math.random()></script>
<script src="OtherJS/tween.min.js?"+Math.random()></script>
<script src="OtherJS/TweenMax.min.js?"+Math.random()></script>
<script src="OtherJS/Scroller.js?"+Math.random()></script>


<script src="src/Page1.js?"+Math.random()></script>
<script src="src/Page2.js?"+Math.random()></script>
<script src="src/Page3.js?"+Math.random()></script>
<script src="src/Page4.js?"+Math.random()></script>
<script src="src/Page5.js?"+Math.random()></script>
<script src="src/ShaderFB.js?"+Math.random()></script>


<script src='http://res.wx.qq.com/open/js/jweixin-1.0.0.js' src-release="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<div style="display:none"><img src='suolue.png' width="400" height="400" />
    <?php
require_once "jssdk.php";
$jssdk = new JSSDK("wx409a5223727cfbde", "3750cb321b4965883f1ccbe1fc945f8d");
$signPackage = $jssdk->GetSignPackage();
    ?></div>
<audio id="Jaudio" class="media-audio" src="sound/bg.mp3"  loop="loop"></audio>
<!--<audio id="music" class="media-audio" src="sound/bg.mp3"  loop="loop"></audio>-->
<!--<audio id="JaudioHit" class="media-audio" src="sound/拳11.mp3"  ></audio>-->
<audio id="JaudioHit" class="media-audio" src="sound/bala.mp3"  ></audio>
<audio id="JaudioHit2" class="media-audio" src="sound/bala.mp3"  ></audio>
<audio id="JaudioHit3" class="media-audio" src="sound/bala.mp3"  ></audio>

<script>
    var main = Main.Create();
</script>
<script>
    var timestamp = Date.parse(new Date());
    timestamp = timestamp / 1000;


    wx.config({
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: '<?php echo $signPackage["appId"];?>',
        timestamp: '<?php echo $signPackage["timestamp"];?>',
        nonceStr: '<?php echo $signPackage["nonceStr"];?>',
        signature: '<?php echo $signPackage["signature"];?>',
        jsApiList: ['onMenuShareAppMessage']

    });
    wx.ready(function () {
        document.getElementById("Jaudio").play();
        document.getElementById("JaudioHit").play();
        document.getElementById("JaudioHit2").play();
        document.getElementById("JaudioHit3").play();

        wx.onMenuShareAppMessage({
            title:'时代听令，前滩先生来了！', // 分享标题
            desc: '大前滩中轴跃级之作', // 分享描述
            link: 'http://www.yixuanhudong.com/ZL/QianTanXianSheng/index.html', // 分享链接
            imgUrl:'http://www.yixuanhudong.com/ZL/QianTanXianSheng/suolue.png',
            success: function () {
//                alert("分享成功！");
            },
            cancel: function () {
                // 用户取消分享后执行的回调函数
            }
        });
    });

    var audio;
    var audio2;
    var audio3;
    var audio4;

    var bl1=false;
    var bl2=false;
    var bl3=false;
    var allTrue=false;
    function getTrue(){
        if(bl1==true&&bl2==true&&bl3==true){
            console.log("All True");
            document.dispatchEvent(new CustomEvent("musicLoaded",{detail:1}));
        }
    }

    document.getElementById("Jaudio").addEventListener("canplay",aa);
    function aa(){
        console.log('canplay1');
        bl1=true;
        getTrue();

        document.getElementById("Jaudio").removeEventListener("canplay",aa);
    }


    document.getElementById("JaudioHit").addEventListener("canplay",bb);
    function bb(){
        console.log('canplay2');
        document.getElementById("JaudioHit").pause();
        bl2=true;
        getTrue();
        document.getElementById("JaudioHit").removeEventListener("canplay",bb);
    }
    document.getElementById("JaudioHit2").addEventListener("canplay",cc)
    function cc(){
        console.log('canplay3');
        document.getElementById("JaudioHit2").pause();
        bl3=true;
        getTrue();
        document.getElementById("JaudioHit2").removeEventListener("canplay",cc);
    }
    document.getElementById("JaudioHit3").addEventListener("canplay",dd)
    function dd(){
        console.log('canplay4');
        document.getElementById("JaudioHit3").pause();
        bl3=true;
        getTrue();
        document.getElementById("JaudioHit3").removeEventListener("canplay",dd);
    }



    function guagua() {
        console.log("audioAutoPlay");
        audioAutoPlay('Jaudio');
    }


    function audioAutoPlay(id) {
        audio = document.getElementById(id)
//        audio.play();
//        audio.pause();

//        audio2= document.getElementById("JaudioHit");
//        audio2.play();
//
//
//        audio3= document.getElementById("JaudioHit2");
//        audio3.play();
//
//
//        audio4= document.getElementById("JaudioHit3");
//        audio4.volume=0.1;
//        audio4.play();


//        document.getElementById("JaudioHit").volume=0;
//        document.getElementById("JaudioHit").play();
//        document.getElementById("JaudioHit").pause();

//        document.getElementById("JaudioHit2").volume=0;
//        document.getElementById("JaudioHit2").play();

//        document.getElementById("JaudioHit2").pause();

//        document.getElementById("JaudioHit3").play();
//        document.getElementById("JaudioHit3").pause();

//                audio.pause();
        music_bl=true;
//        alert(music_bl);
        document.addEventListener("touchstart", play, false);
    }


    function StartMusic() {
        console.log("StartMusic");
        document.addEventListener("WeixinJSBridgeReady", guagua, false);
    }
//    StartMusic();
</script>

</body>
</html>